/* 
 * com.ctvit.framework.service.UserServiceMock.java Create on Apr 23, 2008 4:46:28 PM By Q-Wang 
 * $Header: /home/cvsroot/ctvit/messgeCenter/src/com/ctvit/framework/service/UserServiceMock.java,v 1.1 2015/12/18 01:17:30 yushihao Exp $
 */
package com.ctvit.framework.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.ctvit.framework.domain.BasicUser;

/**
 * @author Q-Wang
 *
 */
public class UserServiceMock extends BaseUserService {
	
	Map userMap = new HashMap();
	
	public UserServiceMock() {
		BasicUser user = new BasicUser();
		user.setUsername("test");
		user.setPassword("test");
		userMap.put(user.getUsername(), user);
	}

	/**
	 * @see com.ctvit.framework.service.BaseUserService#loadUserByUsername(java.lang.String)
	 */
	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException, DataAccessException {
		BasicUser user = (BasicUser) userMap.get(username);
		if (user==null) {
			throw new UsernameNotFoundException("Username:" + username + " Not Found!");
		}
		return user;
	}

}
